# coding=utf-8
##
## Author: jmdvirus@aliyun.com
##
## Create: 2019年01月24日 星期四 17时57分00秒
##

import cv2
from optparse import OptionParser

def takeout_picture(file):
    print("Start with file " + file)
    cam = cv2.VideoCapture(file)
    index = 1
    while cam.isOpened():
        flag, frame = cam.read()
        if flag == True:
            cv2.imwrite("x-" + str(index) + ".jpg", frame)
            index = index + 1
        else:
            break

    print("done")

if __name__ == "__main__":
    parser = OptionParser()
    parser.add_option("-f", dest="file")
    (options, args) = parser.parse_args()
    takeout_picture(options.file)

